package com.guigu.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.ssm.mapper.ShoopMapper;
import com.guigu.ssm.pojo.PageVo;
import com.guigu.ssm.pojo.Shoop;
import com.guigu.ssm.service.ShoopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoopServiceImpl implements ShoopService {

    @Autowired(required = false)
    ShoopMapper dao;

    @Override
    public  PageVo<Shoop> findAll(Integer page, Integer num,String sname,Integer tid) {
        tid=tid==null?0:tid;
        sname=sname==null?"":sname;

        Shoop shoop = new Shoop();
        shoop.setTid(tid);
        shoop.setSname("%"+sname+"%");

        System.out.println(shoop);

        PageHelper.startPage(page,num);
        List<Shoop> all1 = dao.findAll(shoop);
        PageInfo pageInfo1 = new PageInfo(all1);
        PageVo<Shoop> pageVo = new PageVo<>(pageInfo1.getTotal(),pageInfo1.getList());
        return pageVo;
    }
}
